#!/bin/bash

# nmt
function nmtSend() {
    url_nmt="http://test-arch-test01-java02-ws8-rpc001.zhrpc.net/mem/nmt/add/json?serviceName=$1&podName=$2&metricTime=$3"
    nmt_data=$(jcmd 1 VM.native_memory summary scale=MB)
    nmt_data_1=$(echo "$nmt_data" | tr '\n' ' ')
    curl  -X POST $url_nmt -H 'Content-Type: application/json' -d "{\"content\":\"$nmt_data_1\"}"
}
# 获取当前时间并格式化
current_time=$(date +"%Y-%m-%dT%H:%M:%S")
host=$(hostname)
svcName=$(echo $host | sed 's/-[^-]*-[^-]*$//')

nmtSend $svcName $host $current_time
